package
{
	import XMFramework.Core.SError;
	import XMFramework.Interface.IFramework;

	public class EntityUtility
	{
		public static function GetEntityProperty( coreSNSFramework : IFramework, entType : String, propLevel : String, propName : String ) : Object			
		{
			var prop : Object	=	new Object();
			var entityConfig : Object	=	coreSNSFramework.configData.getMetadata( ShareMacros.CONF_ENTITY );
			if( ! entityConfig.hasOwnProperty( entType ) )
			{
				throw new SError( SError.ERR_INTERNAL, null, "EntityUtility::GetFirstProperty - Entity data not found type=" + entType );
				return;
			}
			
			var entityData : Object	=	entityConfig[entType];
			if( entityData.hasOwnProperty( "properties" ) )
			{
				var props : Object	=	entityData.properties[propLevel];		
				var configProperties : Object	=	coreSNSFramework.configData.getMetadata( ShareMacros.CONF_PROPERTIES );
				for( var index : String in props )
				{
					if( propName == index )
					{
						prop	=	configProperties[props[index]];					
						break;
					}
				}
			}
				
			else
				throw new SError( SError.ERR_INTERNAL, null, "FarmHouse::onUpdateSNSItemData - Entity data properties level not found. level=1" );
			
			return prop;
		}
		
		public static function getTypeOfArmyFromServerID( id : String ):String
		{
			return id.split( "_" )[1];//  Soldier type is store locate at index 1 in id string );
		}
		
		public static function getMapIDOfArmyFromServerID( id : String ):String
		{
			return id.split( "_" )[0];//  MapID is store locate at index 0 in id string );
		}

	}
}